#pragma once
// -------------------------------------------------
// BlinKit - BlinKit Library
// -------------------------------------------------
//   File Name: html_element_type_helpers.h
// Description: HTML Element Type Helpers
//      Author: Ziming Li
//     Created: 2022-03-23
// -------------------------------------------------
// Copyright (C) 2022 MingYang Software Technology.
// -------------------------------------------------

#ifndef BLINKIT_HTML_ELEMENT_TYPE_HELPERS_H
#define BLINKIT_HTML_ELEMENT_TYPE_HELPERS_H

#include "blinkit/blink/renderer/core/dom/element.h"
#include "blinkit/blink/renderer/core/HTMLNames.h"

namespace blink {

inline bool isHTMLBodyElement(const Element &element) {
    return element.hasTagName(HTMLNames::bodyTag);
}

inline bool isHTMLBodyElement(const Element *element) {
    return nullptr != element && isHTMLBodyElement(*element);
}

inline bool isHTMLBRElement(const Element &element) {
    return element.hasTagName(HTMLNames::brTag);
}

inline bool isHTMLBRElement(const Node &node) {
    return node.isHTMLElement() && isHTMLBRElement(toElement(node));
}

inline bool isHTMLFormElement(const Element &element) {
    return element.hasTagName(HTMLNames::scriptTag);
}

inline bool isHTMLFormElement(const Element *element) {
    return nullptr != element && isHTMLFormElement(*element);
}

inline bool isHTMLFormElement(const Node &node) {
    return node.isHTMLElement() && isHTMLFormElement(toElement(node));
}

inline bool isHTMLHeadElement(const Element &element) {
    return element.hasTagName(HTMLNames::headTag);
}

inline bool isHTMLHeadElement(const Element *element) {
    return nullptr != element && isHTMLHeadElement(*element);
}

inline bool isHTMLHtmlElement(const Element &element) {
    return element.hasTagName(HTMLNames::htmlTag);
}

inline bool isHTMLHtmlElement(const Element *element) {
    return nullptr != element && isHTMLHtmlElement(*element);
}

inline bool isHTMLInputElement(const Element &element) {
    return element.hasTagName(HTMLNames::inputTag);
}

inline bool isHTMLOptGroupElement(const Element &element) {
    return element.hasTagName(HTMLNames::optgroupTag);
}

inline bool isHTMLOptionElement(const Element &element) {
    return element.hasTagName(HTMLNames::optionTag);
}

inline bool isHTMLScriptElement(const Element &element) {
    return element.hasTagName(HTMLNames::scriptTag);
}

inline bool isHTMLScriptElement(const Node &node) {
    return node.isHTMLElement() && isHTMLScriptElement(toElement(node));
}

inline bool isHTMLStyleElement(const Element &element) {
    return element.hasTagName(HTMLNames::styleTag);
}

inline bool isHTMLStyleElement(const Node &node) {
    return node.isHTMLElement() && isHTMLStyleElement(toElement(node));
}

inline bool isHTMLTemplateElement(const Element &element) {
    return element.hasTagName(HTMLNames::templateTag);
}

inline bool isHTMLTemplateElement(const Node &node) {
    return node.isHTMLElement() && isHTMLTemplateElement(toElement(node));
}

inline bool isHTMLTitleElement(const Element &element) {
    return element.hasTagName(HTMLNames::titleTag);
}

inline bool isHTMLTitleElement(const Element *element) {
    return nullptr != element && isHTMLTitleElement(*element);
}

} // namespace blink

#endif // BLINKIT_HTML_ELEMENT_TYPE_HELPERS_H
